<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>新手专区</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="./css/styleold.css" />
    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/aui-tab.js"></script>
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
    <script type="text/javascript">
        function closeWin() {

            api.closeWin({});
        };
    </script>
</head>

<body>
    <!-- 头部 -->
    <header class="aui-bar aui-bar-nav pos">
        <a class="aui-pull-left aui-btn" onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">新手专区</div>
    </header>
    <div class="header-d"></div>
    <div class="news-region-bg">

        <div id="list">
            <div class="news-region-t">
                <div class="news-region-t-icon"><img src="image/news-region-t-1.png"></div>
                <h3>新手标<span></span></h3>
                <div class="aui-clearfix"></div>
                <div class="news-region-t-1">
                    <span class="news-region-t-1-title">超高收益</span>
                    <div class="aui-clearfix"></div>
                    <span class="news-region-t-1-t">
                    -
                    <div class="news-region-t-1-t-r">
                        <span>年化</span> %
                </div>
                </span>
            </div>
            <div class="news-region-1-d">
                <span><i>-月</i></span>
                <span><i>-元起投</i></span>
                <!-- <span><i>总额10万元</i></span> -->
            </div>
            <div class="news-region-1-btn" onclick="jump_yuebao();">
                <img src="image/news-region-t-btn.png">
                <p>立即购买</p>
            </div>

        </div>

        <div class="news-region-t">
            <div class="news-region-t-icon"><img src="image/news-region-t-1.png"></div>
            <h3>新手标<span></span></h3>
            <div class="aui-clearfix"></div>

            <div class="news-region-t-1">
                <span class="news-region-t-1-title">超高收益</span>
                <div class="aui-clearfix"></div>
                <span class="news-region-t-1-t">
                    -
                    <div class="news-region-t-1-t-r">

                        <span>年化</span>
                        %
                    </div>
                </span>
            </div>
            <div class="news-region-1-d">
                <span><i>-月</i></span>
                <span><i>-元起投</i></span>
                <!-- <span><i>总额10万元</i></span> -->
            </div>
            <!-- <div class="news-region-1-btn-no"> -->
            <div class="news-region-1-btn" onclick="jump_xinshoubiao();">
                <img src="image/news-region-t-btn.png">
                <p>立即购买</p>
            </div>
            </span>
        </div>
        <div class="news-region-1-d">
            <span><i>-月</i></span>
            <span><i>-元起投</i></span>
            <!-- <span><i>总额10万元</i></span> -->
        </div>
        <div class="news-region-1-btn-no">
            <img src="image/news-region-t-btn.png">
            <p>立即购买</p>
        </div>

    </div>
    </div>


    <div class="news-region-d">
        <h2>我的福利</h2>
        <ul>
            <li>
                <!-- 领取前 -->
                <div class="news-region-d-y" id="beforeRegister">
                    <div class="news-region-d-l">
                        <img src="image/news-region-s-1.png">
                    </div>
                    <div class="news-region-d-r">
                        <img src="image/news-region-d-1.png">
                        <div class="news-region-d-r-s">
                            <p>
                                30元
                                <i>注册送</i>
                            </p>
                            <span onclick="registerRedPacket()">立即领取</span>
                        </div>
                    </div>
                    <div class="aui-clearfix"></div>
                </div>
                <!-- 领取后 -->
                <div class="news-region-d-n" id="afterRegister" style="display:none;">
                    <div class="news-region-d-l">
                        <img src="image/news-region-h-1.png">
                    </div>
                    <div class="news-region-d-r">
                        <img src="image/news-region-d-2.png">
                        <div class="news-region-d-r-s">
                            <p>
                                30元
                                <i>注册送</i>
                            </p>
                            <span>30天内使用有效</span>
                        </div>
                        <div class="news-region-d-icon">
                            <img src="image/news-region-t-2.png">
                        </div>
                    </div>
                    <div class="aui-clearfix"></div>
                </div>
            </li>
            <li>
                <!-- 领取前 -->
                <div class="news-region-d-y" id="beforeOpen">
                    <div class="news-region-d-l">
                        <img src="image/news-region-s-2.png">
                        <img src="image/news-region-d-3.png">
                    </div>
                    <div class="news-region-d-r" tapmode>
                        <img src="image/news-region-d-1.png">
                        <div class="news-region-d-r-s">
                            <p>
                                50元
                                <i>开通存管账户送</i>
                            </p>
                            <span onclick="openBank()">立即领取</span>
                        </div>
                    </div>
                    <div class="aui-clearfix"></div>
                </div>
                <!-- 领取后 -->
                <div class="news-region-d-n" id="afterOpen" style="display:none;">
                    <div class="news-region-d-l">
                        <img src="image/news-region-h-2.png">
                        <img src="image/news-region-d-4.png">
                    </div>
                    <div class="news-region-d-r">
                        <img src="image/news-region-d-2.png">
                        <div class="news-region-d-r-s">
                            <p>
                                50元
                                <i>开通存管账户送</i>
                            </p>
                            <span>30天内使用有效</span>
                        </div>
                        <div class="news-region-d-icon">
                            <img src="image/news-region-t-2.png">
                        </div>
                    </div>
                    <div class="aui-clearfix"></div>
                </div>
            </li>
            <li>
                <!-- 领取前 -->
                <div class="news-region-d-y" id="beforeOpenBank">
                    <div class="news-region-d-l">
                        <img src="image/news-region-s-3.png">
                        <img src="image/news-region-d-3.png">
                    </div>
                    <div class="news-region-d-r">
                        <img src="image/news-region-d-1.png">
                        <div class="news-region-d-r-s">
                            <p>
                                88元
                                <i>绑定银行卡</i>
                            </p>
                            <span onclick="openBank()">立即领取</span>
                        </div>
                    </div>
                    <div class="aui-clearfix"></div>
                </div>
                <!-- 领取后 -->
                <div class="news-region-d-n" id="afterOpenBank" style="display:none;">
                    <div class="news-region-d-l">
                        <img src="image/news-region-h-3.png">
                        <img src="image/news-region-d-4.png">
                    </div>
                    <div class="news-region-d-r">
                        <img src="image/news-region-d-2.png">
                        <div class="news-region-d-r-s">
                            <p>
                                88元
                                <i>绑定银行卡</i>
                            </p>
                            <span>30天内使用有效</span>
                        </div>
                        <div class="news-region-d-icon">
                            <img src="image/news-region-t-2.png">
                        </div>
                    </div>
                    <div class="aui-clearfix"></div>
                </div>
            </li>
            <li>
                <!-- 领取前 -->
            <!-- </li>
            <div class="news-region-d-y" id="beforeOpenHrb">
              <div class="news-region-d-l">
                <img src="image/news-region-s-4.png">
                <img src="image/news-region-d-3.png">
              </div>
              <div class="news-region-d-r">
                <img src="image/news-region-d-1.png">
                <div class="news-region-d-r-s">
                  <p>
                    188元
                    <i>绑定哈尔滨银行卡送</i>
                  </p>
                  <span onclick="openBank()">立即领取</span>
                </div>
              </div>
              <div class="aui-clearfix"></div>
            </div> -->
            <!-- 领取后 -->
            <!-- <div class="news-region-d-n" id="afterOpenHrb" style="display:none;">
              <div class="news-region-d-l">
                <img src="image/news-region-h-4.png">
                <img src="image/news-region-d-4.png">
              </div>
              <div class="news-region-d-r">
                 <img src="image/news-region-d-2.png"> -->
                <!-- <div class="news-region-d-r-s">
                  <p>
                    188元
                    <i>绑定哈尔滨银行卡送</i>
                  </p>
                  <span>30天内使用有效</span>
                </div>
                <div class="news-region-d-icon">
                  <img src="image/news-region-t-2.png">
                </div>
              </div>
              <div class="aui-clearfix"></div>
            </div>
            <li>  -->
                <!-- 领取前 -->
                <div class="news-region-d-y" id="beforeLoan">
                    <div class="news-region-d-l">
                        <img src="image/news-region-s-5.png">
                        <img src="image/news-region-d-3.png">
                    </div>
                    <div class="news-region-d-r">
                        <img src="image/news-region-d-1.png">
                        <div class="news-region-d-r-s">
                            <p>
                                188元
                                <i>投标后送</i>
                            </p>
                            <span onclick="openLoan()">立即领取</span>
                        </div>
                    </div>
                    <div class="aui-clearfix"></div>
                </div>
                <!-- 领取后 -->
                <div class="news-region-d-n" id="afterLoan" style="display:none;">
                    <div class="news-region-d-l">
                        <img src="image/news-region-h-5.png">
                        <img src="image/news-region-d-4.png">
                    </div>
                    <div class="news-region-d-r">
                        <img src="image/news-region-d-2.png">
                        <div class="news-region-d-r-s">
                            <p>
                                188元
                                <i>投标后送</i>
                            </p>
                            <span>30天内使用有效</span>
                        </div>
                        <div class="news-region-d-icon">
                            <img src="image/news-region-t-2.png">
                        </div>
                    </div>
                    <div class="aui-clearfix"></div>
                </div>
            </li>
        </ul>
    </div>
    </div>


</body>
<!-- 模板 -->
<script type="text/template" id="template">
    <div class="news-region-t">
        <div class="news-region-t-icon"><img src="image/news-region-t-1.png"></div>
        <h3>{{=it.yuebao.name}}<span></span></h3>
        <div class="aui-clearfix"></div>
        <div class="news-region-t-1">
            <span class="news-region-t-1-title">超高收益</span>
            <div class="aui-clearfix"></div>
            <span class="news-region-t-1-t">
                {{=it.yuebao.rate}}
                <div class="news-region-t-1-t-r">
                    <span>年化</span>

        </div>
        </span>
    </div>
    <div class="news-region-1-d">
        <span><i>{{=it.yuebao.end_date}}截止</i></span>
        <span><i>{{=it.yuebao.min_money}}元起投</i></span>
        <!-- <span><i>总额10万元</i></span> -->
    </div>
    <div class="news-region-1-btn" onclick="jump_yuebao();">
        <img src="image/news-region-t-btn.png">
        <p>立即购买</p>
    </div>
    </div>

    <div class="news-region-t">
        <div class="news-region-t-icon"><img src="image/news-region-t-1.png"></div>
        <h3>{{=it.licai.name}}<span></span></h3>
        <div class="aui-clearfix"></div>
        <div class="news-region-t-1">
            <span class="news-region-t-1-title">超高收益</span>
            <div class="aui-clearfix"></div>
            <span class="news-region-t-1-t">
                {{=it.licai.rate}}
                <div class="news-region-t-1-t-r">
                    <span>年化</span>

        </div>
        </span>
    </div>
    <div class="news-region-1-d">
        <span><i>{{=it.licai.time_limit}}个月</i></span>
        <span><i>{{=it.licai.min_money}}元起投</i></span>
        <!-- <span><i>总额10万元</i></span> -->
    </div>
    <div class="news-region-1-btn" onclick="jump_xinshoubiao();">
        <img src="image/news-region-t-btn.png">
        <p>立即购买</p>
    </div>
    </div>
</script>
<script type="text/javascript">
    var end_date = '';
    var id_yuebao = '';
    var id_xinshoubiao = '';

    apiready = function() {
        var userid = $api.getStorage('userid');
        if (userid) {

            var before = document.getElementById("beforeRegister");
            before.style.display = "none";
            var after = document.getElementById("afterRegister");
            after.style.display = "";
            updateData(userid);
        } else {
            var before = document.getElementById("beforeRegister");
            before.style.display = "";
            var after = document.getElementById("afterRegister");
            after.style.display = "none";
        }



    }

    // 查看红包状态
    function updateData(userid) {
        // alert(userid);
        api.ajax({
            url: webAddress + '/index.php?ctl=app_user_center&act=activity_ecv_list',
            method: 'post',
            data: {
                values: {
                    id: userid,
                },
            }
        }, function(ret, err) {

            if (ret) {
                // alert($api.jsonToStr(ret));
                if (ret.status == 0) {
                    alert(ret.info);
                    return false;
                } else {
                    var ecv_hrb_1 = ret.ecv_hrb_1;
                    if (ecv_hrb_1 == '0') {
                        var before = document.getElementById("beforeOpen");
                        before.style.display = "";
                        var after = document.getElementById("afterOpen");
                        after.style.display = "none";
                    } else {
                        var before = document.getElementById("beforeOpen");
                        before.style.display = "none";
                        var after = document.getElementById("afterOpen");
                        after.style.display = "";
                    }
                    var ecv_hrb_3 = ret.ecv_hrb_3;
                    if (ecv_hrb_3 == '0') {
                        var before = document.getElementById("beforeOpenBank");
                        before.style.display = "";
                        var after = document.getElementById("afterOpenBank");
                        after.style.display = "none";
                    } else {
                        var before = document.getElementById("beforeOpenBank");
                        before.style.display = "none";
                        var after = document.getElementById("afterOpenBank");
                        after.style.display = "";
                    }
                    var ecv_hrb_2 = ret.ecv_hrb_2;
                    if (ecv_hrb_2 == '0') {
                        // var before = document.getElementById("beforeOpenHrb");
                        // before.style.display = "";
                        // var after = document.getElementById("afterOpenHrb");
                        // after.style.display = "none";
                    } else {
                        // var before = document.getElementById("beforeOpenHrb");
                        // before.style.display = "none";
                        // var after = document.getElementById("afterOpenHrb");
                        // after.style.display = "";
                    }
                    var ecv_deal = ret.ecv_deal;
                    if (ecv_deal == '0') {
                        var before = document.getElementById("beforeLoan");
                        before.style.display = "";
                        var after = document.getElementById("afterLoan");
                        after.style.display = "none";
                    } else {
                        var before = document.getElementById("beforeLoan");
                        before.style.display = "none";
                        var after = document.getElementById("afterLoan");
                        after.style.display = "";
                    }


                    end_date = ret.yuebao.end_date;
                    id_yuebao = ret.yuebao.id;
                    id_xinshoubiao = ret.licai.id;
                    templateFun(ret);
                }
            } else {
                alert(err.msg);
            }
        });
    }

    // 模板赋值函数
    function templateFun(data) {

        var template = $api.byId('template');
        var dotFn = doT.template(template.innerHTML);
        var html = dotFn(data);
        var user = $api.byId('list');
        $api.html(user, html);
    }

    function hongbao() {
        var delay = 0;
        if (api.systemType != 'ios') {
            // delay = 300;
        }
        api.openWin({
            name: 'hongbao',
            url: './hongbao.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    };

    function registerRedPacket() {
        api.openFrame({
            name: 'login',
            url: './login.html',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto'
            },
            pageParam: {
                login: 'registerRedPacket'
            },
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true
        });
    }

    function openBank() {
        var userid = $api.getStorage('userid');
        if (!userid) {
            alert('请先登录');
            api.openWin({
                name: 'login',
                url: './login.html',
                pageParam: {
                    login: 'registerRedPacket'
                }
            });
            return false;
        }

        api.openFrame({
            name: 'open-bank',
            url: './open-bank.html',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: '70px',
            },
            pageParam: {
                window: 'index'
            },
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true
        });

        api.openFrame({
            name: 'bank',
            url: './bank.html',
            rect: {
                x: 0,
                y: '70px',
                w: 'auto',
                h: 'auto'
            },
            pageParam: {
                name: 'test'
            },
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true
        });
    }

    // function openLoan() {
    //     // 上页面刷新数据
    //     var refreshLicai = 'gotoLicai();';
    function openLoan(){
        // // 上页面刷新数据
        // var refreshLicai = 'gotoLicai();';
        // api.execScript({
        //     name: 'home',
        //     script: refreshLicai,
        // });

        // // 成功后关闭登录页面
        // api.closeToWin({
        //     name: 'home'
        // });

        var setSele = 'randomSwitchBtn(1);';
        api.execScript({
            name: 'root',
            script: setSele,
        });
        api.closeToWin({
            name: 'root'
        });
    }

    function jump_yuebao() {

        var userid = $api.getStorage('userid');
        if (!userid) {
            alert('请先登录');
            api.openWin({
                name: 'login',
                url: './login.html',
                pageParam: {
                    login: 'registerRedPacket'
                }
            });
            return false;
        }

        api.openWin({
            name: 'syx_buy',
            url: './syx_buy.html',
            pageParam: {
                id: id_yuebao,
                end_date: end_date
            }
        });

        // api.openWin({
        //     name: 'licai_yuebao',
        //     url: './licai-yuebao.html',
        //     pageParam: {
        //         id: id_yuebao,
        //         end_date: end_date
        //     }
        // });

    }

    function jump_xinshoubiao() {
        var userid = $api.getStorage('userid');
        if (!userid) {
            alert('请先登录');
            api.openWin({
                name: 'login',
                url: './login.html',
                pageParam: {
                    login: 'registerRedPacket'
                }
            });
            return false;
        }

        api.openWin({
            name: 'znlc_buy',
            url: './znlc_buy.html',
            pageParam: {
                id: id_xinshoubiao
            }
        });

        // api.openWin({
        //     name: 'licai_zhitou',
        //     url: './licai-zhitou.html',
        //     pageParam: {
        //         id: id_xinshoubiao
        //     }
        // });

    }

    function closeBottomFrame() {

        api.closeFrame({
            name: 'bank'
        });
    };
</script>

</html>
